//
//  OssUtil.m
//  deerkids
//
//  Created by 王昭的Mac Air on 2017/10/19.
//  Copyright © 2017年 wangzhao. All rights reserved.
//

#import "OssUtil.h"

#define OssPath  [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"oss.archive"]
#define OssPathVideo  [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"ossv.archive"]


@implementation OssUtil

//Oss信息获取
+ (OssMessage *)getOssMessage:(NSString *)type
{
    if([@"image" isEqual:type]){
        return [NSKeyedUnarchiver unarchiveObjectWithFile:OssPath];
    }
    return [NSKeyedUnarchiver unarchiveObjectWithFile:OssPathVideo];
}

//Oss信息删除
+ (BOOL)deleteOssMessage
{
    [[NSFileManager defaultManager] removeItemAtPath:OssPathVideo error:nil];
    return [[NSFileManager defaultManager] removeItemAtPath:OssPath error:nil];
}

//Oss信息保存
+ (BOOL)saveOssMessage:(OssMessage *)ossMessage type:(NSString *)type
{
    if([@"image" isEqual:type]){
        return [NSKeyedArchiver archiveRootObject:ossMessage toFile:OssPath];
    }
    return [NSKeyedArchiver archiveRootObject:ossMessage toFile:OssPathVideo];
}


@end
